#include<bits/stdc++.h>
using namespace std;
const int NN=3e6+4,P=998244353;
char s[NN];
int n;
set<string>st;
void dfs(int u,string now)
{
    if(u==n+1)
    {
        st.insert(now);
        return;
    }
    now.push_back(s[u]);
    dfs(u+1,now);
    if(now.size()>=2&&(now[now.size()-2]=='A'&&now.back()=='A'||now[now.size()-2]=='B'))
    {
        now.pop_back(),now.pop_back();
        dfs(u+1,now);
    }
}
int main()
{
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);
    scanf("%s",s+1);
    n=strlen(s+1);
    if(n<=20)
    {
        dfs(1,"");
        printf("%d",st.size());
        return 0;
    }
    if(s[1]=='A')
        n--;
    if(s[n]=='B')
        n--;
    printf("%d",n/2+1);
    return 0;
}